package com.huaboot.framework.log.service;

import com.huaboot.framework.log.dto.OperateLogDto;
import com.huaboot.framework.redis.config.RedisCache;
import com.huaboot.framework.redis.utils.RedisKeyConstant;
import com.huaboot.framework.redis.utils.RedisKeyUtil;
import lombok.AllArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * 操作日志服务
 *
 */
@Service
@AllArgsConstructor
public class OperateLogService {
    private final RedisCache redisCache;

    @Async
    public void saveLog(OperateLogDto log) {
        String key = RedisKeyUtil.generateKey(RedisKeyConstant.SYS_LOG);
        // 保存到Redis队列
        redisCache.leftPush(key, log, RedisCache.NOT_EXPIRE);
    }
}
